package Action;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import Dao.noticedao;
import Dao.openexpdao;
import Entity.Notice;
import Entity.OpenExp;
import Entity.User;
import mapper.Noticemapper;
import mapper.Openexpmapper;

/**
 * Servlet implementation class OpenExpServlet
 */
@WebServlet("/OpenExpServlet")
public class OpenExpServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public OpenExpServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		int num =Integer.parseInt(request.getParameter("num"));
		String context=request.getParameter("context");
		String cTitle=request.getParameter("cTitle");
		 HttpSession session = request.getSession();
		 User user= null;
	     user =(User) session.getAttribute("user");
         String uid = user.getUid();
         OpenExp oe = new OpenExp();
         oe.setcTitle(cTitle);
         oe.setContent(context);
         oe.setUid(uid);
         oe.setNum(num);
         Openexpmapper om = new openexpdao();
         boolean read = !om.CreatOpenExp(oe);
         String sid ="管理员";
         Notice n =new Notice();
         n.setContent(context);
         n.setTitle(cTitle);
         n.setFrom_Id(uid);
         n.setTo_Id(sid);
         Noticemapper nm = new noticedao();
         boolean a =nm.sendMessage(n);
         boolean b=!nm.queryNoticeByUid(uid);
         
         
	}

}
